<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="favicon.ico" />
<link href="user/css/UserCenter.css?v=<?=WEB_VERSION?>" rel="stylesheet" type="text/css" />
<script src="user/js/jquery-1.7.1.min.js?v=<?=WEB_VERSION?>" type="text/javascript" language="javascript"></script>
<script src="user/js/UserWin.min.js?v=<?=WEB_VERSION?>" type="text/javascript" language="javascript"></script>
<script language="javascript" type="text/javascript" src="user/My97DatePicker/WdatePicker.js?v=<?=WEB_VERSION?>"></script>
<title>100课堂英语学习会员中心</title>
</head>
<body>
<?include('userTop.php')?>
<div class="CenterAuto">
	<?
    include('userLeft.php')
    ?>
	<form action="user_done.html" method="post" name="Acrt">
    <div class="CenterRight Color666">
      <?
    include('userMenu.php')
    ?>
    
   		<table width="770" border="0" cellspacing="2">
          <tr class="ColorFFF">
            <td height="30" align="center" valign="middle" bgcolor="#0D6DB7">套餐类型</td>
            <td height="30" align="center" valign="middle" bgcolor="#0D6DB7">单价</td>
            <td height="30" align="center" valign="middle" bgcolor="#0D6DB7">折扣</td>
            <td height="30" align="center" valign="middle" bgcolor="#0D6DB7">总价</td>
          </tr>
           <?
            $product_cnt = count($product);
            $i=0;
            foreach($product as $v){
			?>
          <tr>
            <td height="30" align="center" valign="middle" bgcolor="#E7E7E7"><?=$v['name']?></td>
            <td height="30" align="center" valign="middle" bgcolor="#E7E7E7"><?=number_format($v['price'],2)?>元</td>
            <td height="30" align="center" valign="middle" bgcolor="#E7E7E7"><?=number_format($v['discount'],2)?>元</td>
            <?if($i==0){?>
            <td rowspan="<?=$product_cnt?>" align="center"  valign="middle" bgcolor="#E7E7E7">
                <p style="padding-left:40px;">套餐总数量：<span class="SumUser"><?=$product_cnt?>份</span></p>
                <p style="padding-left:40px;">课程费用总额：<span><?=number_format($sumPrice,2)?></span>元&nbsp;优惠：<span>-<?=number_format($sumDiscount,2)?></span>元</p></p>
                <p>合计：<span><?=number_format($sumPrice-$sumDiscount,2)?></span>元</p>
            </td>
            <?}?>
          </tr>
          <?$i++;}?>
        </table>
      <div class="PublicUserListTitle mt10"><em>代金券</em><span>温馨提示：使用代金券需要点击确认后代金券才能生效</span></div>
         <table width="770" border="0" cellspacing="2">
          <tr class="ColorFFF">
            <td height="30" align="center" valign="middle" bgcolor="#0D6DB7">代金券序列号</td>
            <td height="30" align="center" valign="middle" bgcolor="#0D6DB7">代金券金额</td>
            <td height="30" align="center" valign="middle" bgcolor="#0D6DB7">有效期</td>
            <td align="center" valign="middle" bgcolor="#0D6DB7">是否可用</td>
          </tr>
                      
            <?
            foreach ($voucher as $v){
			?>
          <tr>
            <td height="30" align="center" valign="middle" bgcolor="#E7E7E7"><?=$v['number']?>
            <input type="hidden" id="<?=$v['number']?>" name="ticket_number" value="<?=$v['number']?>"></td>
            <td height="30" align="center" valign="middle" bgcolor="#E7E7E7"><?=number_format($v['price'],2)?>元
            <input type="hidden" id="<?=$v['number']?>_price" name="ticket_price" value="<?=$v['price']?>">
            </td>
            <td height="30" align="center" valign="middle" bgcolor="#E7E7E7"><?=number_format($v['price'],2)?>元</td>
            <td height="30" align="center" valign="middle" bgcolor="#E7E7E7">可以使用</td>
          </tr>
                   <?
			}
			?>
           <tr>
            <td height="30" colspan="4" valign="middle" bgcolor="#E7E7E7">&nbsp;&nbsp;&nbsp;&nbsp;请输入您需要添加的代金券序号：
            	<input type="text"  name="use_number" id="use_number" value=""/>
            	<input type="hidden" value="<?=$sumPrice-$sumDiscount?>" id="total_product_value" name="total_product_value">
		      <span id="use_ticket_info_head" style="display:none">使用代金券后你应支付：</span>
		      <span id="s_pay_money"  style="display:none"></span>
		      <span id="use_ticket_info_tail" style="display: none">&nbsp;&nbsp;元</span>            	
            </td>
           </tr>
        </table>
             <input name="product_id" type="hidden" value="<?=$productId?>"/>
             <input name="userKind" type="hidden" value="<?=$userKind?>"/>
   			 <div class="PublicUserListTitle mt10"><em>当前总金额：</em>
   			 <span class="SumUser"><?=$sumPrice-$sumDiscount?></span>
   			 <span class="SumUser21">元</span></div>
    		<input type="button" class="PublicPrice" value="确认支付"  id="confirm_order"/>
      </div>
    </form>
    <div class="clearc"></div>
</div>
<?
include('userFoot.php')
?>
<script>
$(":input").change(function(){
	var id=$(this).attr("id");
	var use_number_value = $(this).val();
	var total_product_value=$("#total_product_value").val();
	var price=0;
	var s_pay_money = 0;
	if(id=='use_number'){
		price = $("#"+use_number_value+"_price").attr("value");
		if(!isNaN(price)){
			s_pay_money =parseFloat(total_product_value)-parseFloat(price); 
			$("#s_pay_money").attr("style","font-weight:bold; color:#CC0000;");
			$("#use_ticket_info_head").attr("style","display:inline-block");
			$("#use_ticket_info_tail").attr("style","display:inline-block");
			$("#s_pay_money").html(""+s_pay_money);
		}else{
			$("#use_ticket_info_head").attr("style","display:none");
			$("#use_ticket_info_tail").attr("style","display:none");
			$("#s_pay_money").attr("style","display:none");
	  }
	}
})

function GetDateDiff(startTime, endTime, diffType) {
            //将xxxx-xx-xx的时间格式，转换为 xxxx/xx/xx的格式 
            startTime = startTime.replace(/\-/g, "/");
            endTime = endTime.replace(/\-/g, "/");

            //将计算间隔类性字符转换为小写
            diffType = diffType.toLowerCase();
            var sTime = new Date(startTime);      //开始时间
            var eTime = new Date(endTime);  //结束时间
            var divNum = 1;
            switch (diffType) {
                case "second":
                    divNum = 1000;
                    break;
                case "minute":
                    divNum = 1000 * 60;
                    break;
                case "hour":
                    divNum = 1000 * 3600;
                    break;
                case "day":
                    divNum = 1000 * 3600 * 24;
                    break;
                default:
                    break;
            }
            return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(divNum));
  }


$("#confirm_order").click(function(){
// 	var monthly_start_date="";
// 	if($("#monthly_start_date").length>0){
// 		monthly_start_date_value = $("#monthly_start_date").val();
// 		if(monthly_start_date_value.length==""){
// 			monthly_start_date_value = monthly_start_date_value+" 00:00:00";
// 			alert('您好,由于你购买了包月套餐,请填写包月套餐开始日期');
// 			return;
// 		} 	

		var today_date= '<?=date('Y-m-d H:i:s')?>';
// 		var dis_day = GetDateDiff(today_date,monthly_start_date_value, "day");
// 		if(parseFloat(dis_day)>14){
// 			alert('您好,包月套餐开始日期必须在接下来2个星期内');
// 			return;
// 		}	
// 	}
	document.Acrt.submit();
})

</script>
</body>
</html>
